//index.js
//获取应用实例
const AV = require('../../utils/av-weapp.js')

Page({
  data: {
    banner: [],
    goods: [],
    bannerHeight:Math.ceil(290.0/750.0 * getApp.screenWidth)
  },
  
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  },

  getInviteCode:function(options) {
    if(options.uid != undefined) {
      wx.showToast({
        title: '来自用户:' + options.uid + '的分享',
        icon:"success",
        duration:2000
      })
    }
  },

  // 加载banner
  loadBanner:function() {
    var that = this;
    var query = new AV.Query('Banner');

    query.find().then(
      function (bannerObject) {
        var banner = [];
        for(var i = 0; i < bannerObject.length;i++) {
          banner.push(bannerObject[i].get('image').get('url'));
        }

        that.setData(
          {
            banner:banner
          }
        )
      }
    );
  }

})
